/
<template>
  <div>
    <el-drawer
      :destroy-on-close="true"
      title="我是标题"
      :visible.sync="drawer"
      :before-close="handleClose"
    >
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="key">
          <el-input v-model="form.key"></el-input>
        </el-form-item>
        <el-form-item label="name">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="age">
          <el-input v-model="form.age"></el-input>
        </el-form-item>
        <el-form-item label="img">
          <template>
            <el-image :src="form.img"></el-image>
          </template>
        </el-form-item>
        <el-form-item label="address">
          <el-input v-model="form.address"></el-input>
        </el-form-item>
        <el-form-item label="price">
          <el-input v-model="form.price"></el-input>
        </el-form-item>
      </el-form>
    </el-drawer>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        key: "",
        name: "",
        age: "",
        img: "",
        address: "",
      },
    };
  },
  watch: {
    // watch监听 第一个参数写你要监听值， 第二个参数 写你这个值发生改变后执行的函数
    obj: "set_form",
  },
  props: {
    drawer: {
      type: Boolean,
      default: false,
    },
    handleClose: {
      type: Function,
      default: () => {},
    },
    obj: {
      type: Object,
      default: () => {},
    },
  },
  methods: {
    set_form() {
      this.form = this.obj;
    },
    onSubmit() {
      console.log("submit!");
    },
  },
};
</script>

<style></style>
